package com.xiu.weixin.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@WebFilter(filterName = "FirstFilter", urlPatterns = "/*")
public class FirstFilter implements Filter {
	private static final Logger logger = LoggerFactory.getLogger(FirstFilter.class);

	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
		// TODO Auto-generated method stub

	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		System.out.println("进入FirstFilter");
		logger.info("进入FirstFilter");
		HttpServletRequest httprequest = (HttpServletRequest) request;
		System.out.println("当前请求的地址" + httprequest.getServletPath());
		logger.info("当前请求的地址" + httprequest.getServletPath());
		chain.doFilter(request, response);
		System.out.println("离开FirstFilter");
		logger.info("离开FirstFilter");
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub

	}

}
